﻿using System;
using System.Collections.Generic;
using System.Text;

using Obsidian.Utils;
using Obsidian.Edm;
using Obsidian.Data.Sql;
using Oak.Model;

namespace Oak.MagSys.Data
{
    public class IconDA
    {
        internal List<MsIconInfo> SelectList(MsIconQry qry)
        {
            MsIconInfo i = new MsIconInfo();
            IDbHandler dbh = i.CreateHandler();
            dbh.SetFields(i.Fields);
            if (!qry.IconIds.IsNull)
            {
                long[] iconIds = qry.IconIds.SplitLong(',');
                if (iconIds.Length > 0)
                    dbh.Where(i.IconId.In(iconIds));
            }
            dbh.OrderBy(i.Depth);
            dbh.OrderBy(i.SortOrder);
            DataReader dr = dbh.Select();
            return dr.ReadList<MsIconInfo>();
        }

    }
}
